package com.td.module.equipment.dal.mysql.acquisitioninfo;

import com.td.framework.common.pojo.PageResult;
import com.td.framework.mybatis.core.mapper.BaseMapperX;
import com.td.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.td.module.equipment.controller.admin.acquisitioninfo.vo.AcquisitionInfoExportReqVO;
import com.td.module.equipment.controller.admin.acquisitioninfo.vo.AcquisitionInfoPageReqVO;
import com.td.module.equipment.dal.dataobject.acquisitioninfo.AcquisitionInfoDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 设备采集信息 Mapper
 *
 * @author 王翔翔
 */
@Mapper
public interface AcquisitionInfoMapper extends BaseMapperX<AcquisitionInfoDO> {

    default PageResult<AcquisitionInfoDO> selectPage(AcquisitionInfoPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<AcquisitionInfoDO>()
                .eqIfPresent(AcquisitionInfoDO::getStationId, reqVO.getStationId())
                .betweenIfPresent(AcquisitionInfoDO::getMonitorTime, reqVO.getMonitorTime())
                .eqIfPresent(AcquisitionInfoDO::getEKey, reqVO.getEKey())
                .eqIfPresent(AcquisitionInfoDO::getENum, reqVO.getENum())
                .eqIfPresent(AcquisitionInfoDO::getEValue, reqVO.getEValue())
                .betweenIfPresent(AcquisitionInfoDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(AcquisitionInfoDO::getId));
    }

    default List<AcquisitionInfoDO> selectList(AcquisitionInfoExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<AcquisitionInfoDO>()
                .eqIfPresent(AcquisitionInfoDO::getStationId, reqVO.getStationId())
                .betweenIfPresent(AcquisitionInfoDO::getMonitorTime, reqVO.getMonitorTime())
                .eqIfPresent(AcquisitionInfoDO::getEKey, reqVO.getEKey())
                .eqIfPresent(AcquisitionInfoDO::getENum, reqVO.getENum())
                .eqIfPresent(AcquisitionInfoDO::getEValue, reqVO.getEValue())
                .betweenIfPresent(AcquisitionInfoDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(AcquisitionInfoDO::getId));
    }


    Integer sumWaterQuality();

    default List<AcquisitionInfoDO> selectGroupMonitorTime(AcquisitionInfoPageReqVO pageReqVO){
        return selectList(new LambdaQueryWrapperX<AcquisitionInfoDO>()
                .eqIfPresent(AcquisitionInfoDO::getStationId, pageReqVO.getStationId())
                .betweenIfPresent(AcquisitionInfoDO::getMonitorTime, pageReqVO.getMonitorTime()));
    }
}
